package com.adminx.dao.impl;

import com.adminx.dao.UserDao;
import com.adminx.po.User;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import java.util.List;

public class UserDaoImpl extends BaseDao implements UserDao {

    private Logger logger = LogManager.getLogger(UserDaoImpl.class) ;
    @Override
    public List<User> selectUserList(String keywords, Integer userListRoleId) {
        return null;
    }

    @Override
    public User findUser(String loginName, String password) {
        String sql = "SELECT userId, userName, loginName, status, roleId FROM t_user WHERE loginName=? and password=?" ;
        logger.info("find user by sql: {} with parameters: {} {}. ", sql, loginName, password) ;
        this.doQuery(sql, loginName, password);
        try {
            if (this.rs.next()) {
                User user = new User() ;
                user.setUserId(this.rs.getInt(1));
                user.setLoginName(this.rs.getString(2));
                user.setUserName(this.rs.getString(3)) ;
                user.setStatus(this.rs.getString(4));
                user.setRoleId(rs.getInt(5));
                return user ;
            }
        } catch (Exception e) {
            logger.error("query failed : {}", e.getMessage());
        }
        return null;
    }

    @Override
    public User getUserByUserId(Integer userId) {
        return null;
    }

    @Override
    public User getUserByLoginName(String loginName) {
        return null;
    }

    @Override
    public int addUser(User user) {
        return 0;
    }

    @Override
    public int updateUser(User user) {
        return 0;
    }

    @Override
    public int delUser(Integer userId) {
        return 0;
    }

    @Override
    public int setUserStatus(User user) {
        return 0;
    }
}
